# 构建阶段
FROM 10.6.64.142/hy/shared/ubuntu:22.04 as builder

COPY openjdk-21_linux-x64_bin.tar.gz jdk21.tar.gz

RUN apt-get update && \
    tar -xzf jdk21.tar.gz && \
    rm jdk21.tar.gz

# 最终镜像
FROM 10.6.64.142/hy/shared/ubuntu:22.04

ENV JAVA_HOME=/opt/jdk-21
ENV PATH=$JAVA_HOME/bin:$PATH

COPY --from=builder /jdk-21 $JAVA_HOME

# 仅保留运行时依赖
RUN apt-get update && \
    apt-get install -y --no-install-recommends libc6 && \
    rm -rf /var/lib/apt/lists/*

# 设置时区（无需交互）
RUN apt-get update && \
    apt-get install -y --no-install-recommends tzdata && \
    ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    echo "Asia/Shanghai" > /etc/timezone && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app
